import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 沈明月
 * Date: 2022-11-03
 * Time: 12:01
 */
public class TestTwentyOne {
//汉诺塔（也称河内塔）问题：
    public static  void hannuota(int n,char pos1,char pos2,char pos3){
    if (n == 1){
        move(pos1,pos3);
        return;
    }
    hannuota(n-1,pos1,pos3,pos2);
    move(pos1,pos3);
    hannuota(n-1,pos2,pos1,pos3);
    }
    public static void move(char pos1,char pos2)
    {
        System.out.print(pos1+"->"+pos2+" ");
    }
    public static void main(String[] args) {
        hannuota(3,'A','B','C');
    }
}
